<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Visualizar Folha de Pagamento</h2>
        </ui:define>

        <ui:define name="body">

            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Editar" icon="ui-icon-pencil" styleClass="ui-priority-primary"
                              href="editarfolhapagamento.xhtml?eFolhaPagamento=#{managerPesquisarFolhaPagamento.folhaPagamentoVisualizar.id}" />
                </div>
            </p:panel>

            <h:form id="folhaPagamentoForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="false" autoUpdate="true"  />
                <p>
                    <p:panel id="folhaPagamentoPanel" styleClass="container_24 clearfix" >

                        <p:outputLabel value="Data:" styleClass="grid_3" for="dataInputText" />
                        <p:inputText id="dataInputText" 
                                     value="#{managerPesquisarFolhaPagamento.folhaPagamentoVisualizar.dataFolhaPagamento}"
                                     styleClass="grid_8" readonly="true" >
                            <f:convertDateTime pattern="dd/MM/yyyy" locale="pt-br" />
                        </p:inputText>
                        <div class="clear"/>

                        <p:outputLabel value="Secretaria:" styleClass="grid_3" for="secretariaInputText"/>
                        <p:inputText id="secretariaInputText" styleClass="grid_18" 
                                     readonly="true" value="#{managerPesquisarFolhaPagamento.secretariaVisualizar.nome}" />
                        <br/>
                    </p:panel>

                    <p:panel id="itensPagamentoPanel" styleClass="container_24 clearfix" >
                        <p:dataTable id="itensPagamentoDataTable" var="item" value="#{managerPesquisarFolhaPagamento.itensFolhaPagamentoVisualizar}" 
                                     styleClass="grid_24" emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Itens da Folha de Pagamento
                            </f:facet>

                            <p:column headerText="Nome" style="vertical-align: middle">
                                #{managerCriarFolhaPagamento.pessoaFisica ? item.pessoa.nome : item.pessoa.nomeFantasia}
                            </p:column>

                            <p:column headerText="Remuneração" width="300" style="text-align: center; vertical-align: middle">
                                <h:outputLabel id="valorInputText" styleClass="grid_7" 
                                             onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );"
                                             value="#{item.valor}" >
                                    <f:convertNumber type="currency" locale="pt,BR"/>
                                </h:outputLabel>
                            </p:column> 

                        </p:dataTable>
                    </p:panel>

                    <br/>
                    <h2>Anexos</h2>

                    <p:panel id="anexoPanel" styleClass="container_24 clearfix" >

                        <p:panel id="anexosPanel" styleClass="container_24 clearfix arquivosAnexadosPanel" header="Arquivos anexados">

                            <ui:repeat value="#{managerPesquisarFolhaPagamento.folhaPagamentoVisualizar.anexos}" var="a">
                                <p:panel styleClass="grid_5">
                                    <h:outputLink  
                                        value="#{a.tipo ne 'application/pdf' ? 'viewImage.xhtml':'show'}" title="#{a.tipo}"  target="_blank" >

                                        <div style="width: 100%;" class="grid_4">

                                            <p:graphicImage id="anexoImagem"
                                                            styleClass="image grid_3" rendered="#{a.tipo ne 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;"
                                                            url="show/?annex=#{a.url.concat('thumbnail.').concat(a.nome)}" />

                                            <p:graphicImage id="anexoPdf"
                                                            styleClass="image grid_3" rendered="#{a.tipo eq 'application/pdf'}"
                                                            style="margin-left:3%; width: 80px;" 
                                                            url="media/images/pdf.jpeg" />

                                            <div class="clear"/>
                                            <p:outputLabel  value="#{managerPesquisarFolhaPagamento.nomeAnexo(a)}" 
                                                            for="anexoImagem"
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.tipo ne 'application/pdf'}"/>

                                            <p:outputLabel for="anexoPdf"
                                                           value="#{managerPesquisarFolhaPagamento.nomeAnexoPdf(a)}" 
                                                           style="margin-left:1%; width: 100px;" rendered="#{a.tipo eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.url.concat(a.nome)}"/>
                                    </h:outputLink>

                                </p:panel>
                            </ui:repeat>
                        </p:panel>
                        <hr style="margin-top: -10px"/>
                        <div class="clear" />
                    </p:panel>

                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="pesquisarfolhapagamento.xhtml" />
                    </div>
                </p>
            </h:form>

        </ui:define>
    </ui:composition>
</html>


